package com.example.yibu.modelConfig.ascPool;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;

import java.lang.reflect.Method;

/**
 * 异步线程报错处理
 *
 */
public class AsyncError implements AsyncUncaughtExceptionHandler {

    /**
     * 异步线程报错处理
     * @param ex 异常
     * @param method 方法
     * @param params 参数
     */
    //日志
    private static final Logger log = LoggerFactory.getLogger(AsyncError.class);


    @Override
    public void handleUncaughtException(Throwable ex, Method method, Object... params) {
        //打印异常信息
        log.error("异常信息 - " + ex.getMessage());
        log.error("报错方法名 - " + method.getName());
        for (Object param : params) {
            log.error("参数值 - " + param);
        }

    }
}
